/******************************************************************************
 * * call_ui.c - UI display of call module
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/

#include "call_global.h"

/**
 * Common Process UI Create event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_Common_Create(VOID *pDesc)
{
    g_MMI_Call_Mng.CurrentDesc = pDesc;
}

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_Common_Destory(VOID *pDesc)
{
    Hal_Mem_Free(pDesc);
    g_MMI_Call_Mng.CurrentDesc = NULL;
}

/**
 * Common Process UI save event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_Common_Save(VOID *pDesc)
{
    g_MMI_Call_Mng.CurrentDesc = NULL;
}

/**
 * Common Process UI restore event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_Common_Restore(VOID *pDesc)
{
    g_MMI_Call_Mng.CurrentDesc = pDesc;
}

/**
 * Process Calling On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Calling(VOID *pDesc)
{
    INT8                                TempChar[64];
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pTmpDesc
        = (UI_Normal_NoTitle_Labels_Bar_Desc_t *)pDesc;

    Call_Common_Create(pDesc);

    lv_obj_set_hidden(pTmpDesc->Bar.Bar, TRUE);                 // Hide volume bar at beginning

    /* set called name */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name != NULL)
    {
        sprintf(TempChar, "%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
        lv_label_set_text(pTmpDesc->ContLabel[1].Label, TempChar);

        lv_obj_align(pTmpDesc->ContLabel[2].Label, pTmpDesc->ContLabel[1].Label,
                     LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 2);
    }

    /* set called number */
    lv_label_set_text(pTmpDesc->ContLabel[2].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);

    lv_obj_set_y(lv_obj_get_parent(pTmpDesc->ContLabel[3].Label),
                 lv_obj_get_y(pTmpDesc->ContLabel[2].Label)
                 + lv_obj_get_height(pTmpDesc->ContLabel[2].Label) + 2);
}

/**
 * display Call_Calling
 * common ui: UI_Normal_NoTitle_Labels_Bar_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Calling(VOID)
{
    Nav_Func_List_t                     FuncList;
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Labels_Bar_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Calling;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc =
        (UI_Normal_NoTitle_Labels_Bar_Desc_t *)Hal_Mem_Alloc(sizeof(
                                                                 UI_Normal_NoTitle_Labels_Bar_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_NoTitle_Labels_Bar_Desc_t));

    /* set title bar */
    pDesc->ContLabel[0].TxtId  = PHONE_TEXT_ID_CALLING;             // Calling...
    pDesc->ContLabel[0].ImgSrc = IMG_CALL_OUTGOING;

    /* set called Name */
    pDesc->ContLabel[1].TxtId       = LV_LANG_TXT_ID_NONE;          // Name set after ui created
    pDesc->ContLabel[1].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[1].SymbolId    = NULL;
    pDesc->ContLabel[1].SymbolAlign = LV_LABEL_ALIGN_LEFT;

    /* set called number */
    pDesc->ContLabel[2].TxtId    = LV_LANG_TXT_ID_NONE;
    pDesc->ContLabel[2].TxtAlign = LV_LABEL_ALIGN_RIGHT;

    /* set calling SIM */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->SimId == MMI_MODEM_SIM_1)
    {
        pDesc->ContLabel[3].TxtId  = PHONE_TEXT_ID_SIM1;
        pDesc->ContLabel[3].ImgSrc = SYMBOL_SIM1;
    }
    else
    {
        pDesc->ContLabel[3].TxtId  = PHONE_TEXT_ID_SIM2;
        pDesc->ContLabel[3].ImgSrc = SYMBOL_SIM2;
    }
    pDesc->ContLabel[3].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[3].SymbolAlign = LV_LABEL_ALIGN_LEFT;

    pDesc->Bar.Range = UI_CALL_SPK_VOL_LEVEL_NUM;
    UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_HANDSET_OFFSET, 1, &(pDesc->Bar.Value));    // read speaker volume from NVM

    /* set button bar */
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_END_CL;
    pDesc->KeyFunc                 = Call_Key_Proc_Calling;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_CALLING, &FuncList, pDesc);
} /* Display_Call_Calling */

/**
 * update time of call main
 * param (in) Seconds: UINT32
 * return void
 */
VOID Call_Update_Call_Display(INT32 Seconds)
{
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pTmpDesc;
    INT8                                TimeChar[10];
    UINT16                              Hour;
    UINT8                               Min, Sec;
    UINT8                               i;
    INT8                                TempChar[64];
    INT8                                *CallId;

    if ((TRUE == g_MMI_Call_Mng.IsConnect) && (ACT_ID_CALL_MAIN == Nav_Get_Top()))
    {   // call main is on showing
        // update call info display
        pTmpDesc = (UI_Normal_NoTitle_Labels_Bar_Desc_t *)g_MMI_Call_Mng.CurrentDesc;

        for (i = 0; i < 2; i++)
        {
            if (NULL == g_MMI_Call_Mng.Calls[i])
            {
                lv_label_set_text(pTmpDesc->ContLabel[i].Label, "");
                lv_obj_set_hidden(pTmpDesc->ContLabel[i].Img, TRUE);
                continue;
            }

            /* set called Name/Number */
            if (g_MMI_Call_Mng.Calls[i]->Name != NULL)
            {
                CallId = g_MMI_Call_Mng.Calls[i]->Name;
            }
            else
            {
                CallId = g_MMI_Call_Mng.Calls[i]->Number;
            }

            if (MMI_MODEM_CALL_STATE_ACTIVE == g_MMI_Call_Mng.Calls[i]->State)
            {
                lv_img_set_src(pTmpDesc->ContLabel[i].Img, IMG_CALL_CALLING);
                sprintf(TempChar, "%s", CallId);
            }
            else if (MMI_MODEM_CALL_STATE_WAITING == g_MMI_Call_Mng.Calls[i]->State)
            {
                // symbol flash between SYMBOL_CALL and SYMBOL_BELL every second
                if (UI_CALL_PROCESS_MT_REJECT != g_MMI_Call_Mng.CallProcess)
                {
                    lv_img_set_src(pTmpDesc->ContLabel[i].Img, IMG_CALL_INCOMING);
                    sprintf(TempChar, "%s", CallId);
                }
                else
                {   // process cal wating reject
                    lv_img_set_src(pTmpDesc->ContLabel[i].Img, IMG_CALL_END);
                    sprintf(TempChar, "%s", CallId);
                }
            }
            else if (MMI_MODEM_CALL_STATE_HOLDING == g_MMI_Call_Mng.Calls[i]->State)
            {
                lv_img_set_src(pTmpDesc->ContLabel[i].Img, IMG_CALL_HOLD);
                sprintf(TempChar, "%s", CallId);
            }
            else
            {
                UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_ERROR, "Call State error\n");
                sprintf(TempChar, "%s", CallId);
            }

            lv_obj_set_hidden(pTmpDesc->ContLabel[i].Img, FALSE);
            lv_label_set_text(pTmpDesc->ContLabel[i].Label, TempChar);
        }

        // update button display
        if (TRUE == Call_Is_Call_Waiting_Present())
        {
            lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_ANSWER));
        }
        else
        {
            if (HAL_CALL_SPK_ON == g_MMI_Call_Mng.CallSpkStatus)
            {
                lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_HANDS));
            }
            else
            {
                lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_LOUDSP));
            }
        }

        // update time display
        Hour = Seconds / 3600;
        Min  = (Seconds % 3600) / 60;
        Sec  = (Seconds % 3600) % 60;
        sprintf(TimeChar, "%.2d:%.2d:%.2d", Hour, Min, Sec);
        lv_label_set_text(pTmpDesc->ContLabel[2].Label, TimeChar);
        lv_obj_set_hidden(pTmpDesc->ButtonBar.ButtonL.Button, FALSE);
    }
} /* Call_Update_Call_Display */

/**
 * Process Call Main On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Call_Main(VOID *pDesc)
{
    UINT8                               SpeakerVol;
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pTmpDesc
        = (UI_Normal_NoTitle_Labels_Bar_Desc_t *)pDesc;

    Call_Common_Create(pDesc);

    lv_obj_set_hidden(pTmpDesc->ButtonBar.ButtonL.Button, TRUE); // Hide opt button at beginning
    lv_obj_set_hidden(pTmpDesc->ContLabel[1].Img, TRUE);         // Hide line2 at begingning
    lv_obj_set_hidden(pTmpDesc->Bar.Bar, TRUE);                  // Hide volume bar at beginning

    /* set called Name, only calls[0] should be handle when creating */
    if (g_MMI_Call_Mng.Calls[0]->Name != NULL)
    {
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
    }
    else
    {
        /* set called number */
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }

    // update button display
    if (TRUE == Call_Is_Call_Waiting_Present())
    {
        lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_ANSWER));
    }
    else
    {
        if (HAL_CALL_SPK_ON == g_MMI_Call_Mng.CallSpkStatus)
        {
            lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_HANDS));
            UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_SPEAKER_OFFSET, 1, &SpeakerVol);
            lv_bar_set_value(pTmpDesc->Bar.Bar, SpeakerVol, LV_ANIM_OFF);
        }
        else
        {
            lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_LOUDSP));
            UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_HANDSET_OFFSET, 1, &SpeakerVol);
            lv_bar_set_value(pTmpDesc->Bar.Bar, SpeakerVol, LV_ANIM_OFF);
        }
    }
}

/**
 * Process Main On restore event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Restore_Call_Main(VOID *pDesc)
{
    UINT8                               SpeakerVol;
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pTmpDesc = (UI_Normal_NoTitle_Labels_Bar_Desc_t *)pDesc;

    Call_Common_Restore(pDesc);

    lv_obj_set_hidden(pTmpDesc->ButtonBar.ButtonL.Button, TRUE); // Hide opt button at beginning
    lv_obj_set_hidden(pTmpDesc->ContLabel[1].Img, TRUE);         // Hide line2 at begingning
    lv_obj_set_hidden(pTmpDesc->Bar.Bar, TRUE);                  // Hide volume bar at beginning

    if (g_MMI_Call_Mng.Calls[0]->Name != NULL)
    {
        /* set called Name */
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
    }
    else
    {
        /* set called number */
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }

    // update button display
    if (TRUE == Call_Is_Call_Waiting_Present())
    {
        lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_ANSWER));
    }
    else
    {
        if (HAL_CALL_SPK_ON == g_MMI_Call_Mng.CallSpkStatus)
        {
            lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_HANDS));
            UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_SPEAKER_OFFSET, 1, &SpeakerVol);
            lv_bar_set_value(pTmpDesc->Bar.Bar, SpeakerVol, LV_ANIM_OFF);
        }
        else
        {
            lv_label_set_text(lv_obj_get_child(pTmpDesc->ButtonBar.ButtonR.Button, NULL), lv_lang_get_text(PHONE_TEXT_ID_LOUDSP));
            UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_HANDSET_OFFSET, 1, &SpeakerVol);
            lv_bar_set_value(pTmpDesc->Bar.Bar, SpeakerVol, LV_ANIM_OFF);
        }
    }

    /* update call main UI*/
    Call_Update_Call_Display(g_MMI_Call_Mng.CallDuration - 1);                      // duration start from 1
} /* Call_On_Restore_Call_Main */

/**
 * display Call_Main
 * common ui: UI_Normal_NoTitle_Labels_Bar_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Main(VOID)
{
    Nav_Func_List_t                     FuncList;
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Labels_Bar_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Call_Main;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_On_Restore_Call_Main;

    pDesc =
        (UI_Normal_NoTitle_Labels_Bar_Desc_t *)Hal_Mem_Alloc(sizeof(
                                                                 UI_Normal_NoTitle_Labels_Bar_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_NoTitle_Labels_Bar_Desc_t));

    /* set 1st Called Name/Number */
    pDesc->ContLabel[0].TxtId       = LV_LANG_TXT_ID_NONE;
    pDesc->ContLabel[0].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[0].SymbolId    = NULL;
    pDesc->ContLabel[0].SymbolAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[0].ImgSrc      = IMG_CALL_CALLING;

    /* set 2nd called Name/Number */
    pDesc->ContLabel[1].TxtId       = LV_LANG_TXT_ID_NONE;
    pDesc->ContLabel[1].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[1].SymbolId    = NULL;
    pDesc->ContLabel[1].SymbolAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[1].ImgSrc      = IMG_CALL_CALLING;

    /* set called Time */
    pDesc->ContLabel[2].TxtId    = LV_LANG_TXT_ID_NONE;
    pDesc->ContLabel[2].TxtAlign = LV_LABEL_ALIGN_RIGHT;

    /* set calling SIM */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->SimId == MMI_MODEM_SIM_1)
    {
        pDesc->ContLabel[3].TxtId  = PHONE_TEXT_ID_SIM1;
        pDesc->ContLabel[3].ImgSrc = SYMBOL_SIM1;
    }
    else
    {
        pDesc->ContLabel[3].TxtId  = PHONE_TEXT_ID_SIM2;
        pDesc->ContLabel[3].ImgSrc = SYMBOL_SIM2;
    }
    pDesc->ContLabel[3].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[3].SymbolAlign = LV_LABEL_ALIGN_LEFT;

    pDesc->Bar.Range = UI_CALL_SPK_VOL_LEVEL_NUM;
    UI_NV_Read_Req(NV_SECTION_UI_CALL, 0, 1, &(pDesc->Bar.Value));    // read speaker volume from NVM

    /* set button bar */
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_LOUDSP;
    pDesc->ButtonBar.ButtonL.Valid = TRUE;
    pDesc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_OPT;
    pDesc->KeyFunc                 = Call_Key_Proc_Main;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_MAIN, &FuncList, pDesc);

    g_MMI_Call_Mng.IsMute = FALSE;                                   // Init to not mute
} /* Display_Call_Main */

/**
 * Process Incoming On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Incoming(VOID *pDesc)
{
    INT8                                TempChar[64];
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pTmpDesc
        = (UI_Normal_NoTitle_Labels_Bar_Desc_t *)pDesc;

    Call_Common_Create(pDesc);

    lv_label_set_text(pTmpDesc->ContLabel[3].Label, "");
    lv_obj_set_hidden(pTmpDesc->Bar.Bar, TRUE);

    /* set called Name */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name != NULL)
    {
        sprintf(TempChar, "%s%s", LV_SYMBOL_CALL, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, TempChar);
    }
    else
    {
        /* set called number */
        sprintf(TempChar, "%s%s", LV_SYMBOL_CALL, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
        lv_label_set_text(pTmpDesc->ContLabel[0].Label, g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }
}

/**
 * display Call_Incoming
 * common ui: UI_Normal_NoTitle_Labels_Bar_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Incoming(VOID)
{
    Nav_Func_List_t                     FuncList;
    UI_Normal_NoTitle_Labels_Bar_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Labels_Bar_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Incoming;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc =
        (UI_Normal_NoTitle_Labels_Bar_Desc_t *)Hal_Mem_Alloc(sizeof(
                                                                 UI_Normal_NoTitle_Labels_Bar_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_NoTitle_Labels_Bar_Desc_t));

    /* set called Name */
    pDesc->ContLabel[0].TxtId       = LV_LANG_TXT_ID_NONE;          // Name set after ui created
    pDesc->ContLabel[0].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[0].SymbolId    = NULL;
    pDesc->ContLabel[0].SymbolAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[0].ImgSrc      = IMG_CALL_INCOMING;

    /* set calling bar */
    pDesc->ContLabel[1].TxtId       = PHONE_TEXT_ID_CALLING;        // Calling...
    pDesc->ContLabel[1].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[1].SymbolId    = NULL;
    pDesc->ContLabel[1].SymbolAlign = LV_LABEL_ALIGN_LEFT;

    /* set calling SIM */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->SimId == MMI_MODEM_SIM_1)
    {
        pDesc->ContLabel[2].TxtId  = PHONE_TEXT_ID_SIM1;
        pDesc->ContLabel[2].ImgSrc = SYMBOL_SIM1;
    }
    else
    {
        pDesc->ContLabel[2].TxtId  = PHONE_TEXT_ID_SIM2;
        pDesc->ContLabel[2].ImgSrc = SYMBOL_SIM2;
    }
    pDesc->ContLabel[2].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel[2].SymbolAlign = LV_LABEL_ALIGN_LEFT;

    pDesc->Bar.Range = UI_CALL_SPK_VOL_LEVEL_NUM;
    UI_NV_Read_Req(NV_SECTION_UI_CALL, CALL_NV_HANDSET_OFFSET, 1, &(pDesc->Bar.Value));    // read speaker volume from NVM

    /* set button bar */
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_SILENCE;
    pDesc->KeyFunc                 = Call_Key_Proc_Incoming;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_INCOMING, &FuncList, pDesc);
} /* Display_Call_Incoming */

/**
 * Process CAll Select Sim On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
UINT8 Call_Get_Conn_Cnt(void)
{
    UINT8 ConnectCnt = 0;

    if (NULL != g_MMI_Call_Mng.Calls[0])
    {
        ConnectCnt++;
    }
    if (NULL != g_MMI_Call_Mng.Calls[1])
    {
        ConnectCnt++;
    }
    return(ConnectCnt);
}

/**
 * Process CAll Select Sim On Destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Destroy_Call_Opt(VOID *pDesc)
{
    UI_Normal_List_Only_Desc_t *pTmpDesc
        = (UI_Normal_List_Only_Desc_t *)pDesc;

    Hal_Mem_Free(pTmpDesc->List.ButtonList);
    Call_Common_Destory(pDesc);
}

/**
 * display Call_Opt
 * common ui: UI_Nbbbormal_List_Only_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Opt(VOID)
{
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDesc;
    UI_Button_Desc_t           *pBtnList;
    UI_Call_Params_t           *CallParams;
    UINT8                      BtnCnt;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_Common_Create;
    FuncList.OnDestroy      = Call_On_Destroy_Call_Opt;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    if (NULL != pDesc)
    {
        memset(pDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));
    }
    else
    {
        // assert;
    }
    // todo: malloc for button list
    // set title bar
    pDesc->TitleBar.TxtId    = PHONE_TEXT_ID_CALL_OPT;
    pDesc->TitleBar.TxtAlign = LV_LABEL_ALIGN_CENTER;

    pDesc->List.Index = 0;
    // set Buttons
    /* Hold/Unhold <1 connected>
     * Reject  < 1 connected && in call waiting process >
     * New call <1 connected> todo:: low priority
     * End active call
     * Swap <2 connected>
     * Conference <2 connected> todo:: low priority
     * End all calls <2 connected>
     * Contacts
     * Menu
     * Mute/Unmute <connected>
     * Loudspeaker/Handset */
    if (1 == Call_Get_Conn_Cnt())
    {     // 1 connection
        if (TRUE == Call_Is_Call_Waiting_Present())
        { // in call waiting process, 7 buttons
            BtnCnt = 7;
        }
        else
        {
            BtnCnt = 6;
        }
    }
    else
    {   // 2 connections has 7 buttons
        BtnCnt = 7;
    }
    pBtnList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * BtnCnt);
    memset(pBtnList, 0, sizeof(UI_Button_Desc_t) * BtnCnt);

    pDesc->List.ButtonList = pBtnList;
    CallParams             = g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex];

    if ((1 == Call_Get_Conn_Cnt()) || TRUE == Call_Is_Call_Waiting_Present())
    {   // 1 connection present
        // set Hold/Unhold button
        pBtnList[pDesc->List.ListButtonCnt].Valid       = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex = pDesc->List.ListButtonCnt;
        if (MMI_MODEM_CALL_STATE_HOLDING == CallParams->State)
        {
            pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_UNHOLD;
        }
        else
        {
            pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_HOLD;
        }
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Hold;

        // set reject
        if (TRUE == Call_Is_Call_Waiting_Present())
        {
            // set reject button
            pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
            pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
            pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_REJECT;
            pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Reject;
        }

        // set End active call
        pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
        pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_END_CALL;
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_End_Act;
    }
    else
    {     // 2 connections present
        // set End active call
        pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
        pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_END_CALL;
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_End_Act;

        // set Swap
        pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
        pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_SWAP;
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Swap;

        // set End all Calls
        pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
        pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_END_ALL_CALL;
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_End_All;
    }

    // set Contacts
    pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
    pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
    pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_CONTACT;
    pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Contacts;

    // set Menu
    pBtnList[pDesc->List.ListButtonCnt].Valid        = TRUE;
    pBtnList[pDesc->List.ListButtonCnt].ButtonIndex  = pDesc->List.ListButtonCnt;
    pBtnList[pDesc->List.ListButtonCnt].TxtId        = PHONE_TEXT_ID_MENU;
    pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Menu;

    if (MMI_MODEM_CALL_STATE_ACTIVE == CallParams->State)
    {       // in connection mode
            // set Mute/UnMute
        pBtnList[pDesc->List.ListButtonCnt].Valid       = TRUE;
        pBtnList[pDesc->List.ListButtonCnt].ButtonIndex = pDesc->List.ListButtonCnt;
        if (TRUE == g_MMI_Call_Mng.IsMute)
        {
            pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_UNMUTE;
        }
        else
        {
            pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_MUTE;
        }
        pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Mute;
    }

    // set Loudspeaker/Handset
    pBtnList[pDesc->List.ListButtonCnt].Valid       = TRUE;
    pBtnList[pDesc->List.ListButtonCnt].ButtonIndex = pDesc->List.ListButtonCnt;
    if (HAL_CALL_SPK_ON == g_MMI_Call_Mng.CallSpkStatus)
    {
        pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_HANDS;
    }
    else
    {
        pBtnList[pDesc->List.ListButtonCnt].TxtId = PHONE_TEXT_ID_LOUDSPEAKER;
    }
    pBtnList[pDesc->List.ListButtonCnt++].ReleaseFun = Call_Rel_Func_Call_Opt_Loudsp;

    /* set button bar */
    pDesc->BtnBar.ButtonR.Valid = TRUE;
    pDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_EXIT;
    pDesc->BtnBar.ButtonM.Valid = TRUE;
    pDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    // Set key proc func
    pDesc->KeyFunc = Call_Key_Proc_Opt;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_OPT, &FuncList, pDesc);
} /* Display_Call_Opt */

/**
 * Process Call End On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Call_End(VOID *pDesc)
{
    INT8                   TempChar[64];
    UI_Status_Label_Desc_t *pTmpDesc = (UI_Status_Label_Desc_t *)pDesc;

    Call_Common_Create(pDesc);

    /* set called Name or number */
    if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name != NULL)
    {
        sprintf(TempChar, "%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
    }
    else
    {
        sprintf(TempChar, "%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }
    lv_label_set_text(pTmpDesc->ContLabel[0].Label, TempChar);
}

/**
 * display Call_End
 * common ui: UI_Status_Label_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_End(VOID)
{
    Nav_Func_List_t        FuncList;
    UI_Status_Label_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Label_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Call_End;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc = (UI_Status_Label_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Label_Desc_t));
    memset(pDesc, 0, sizeof(UI_Status_Label_Desc_t));

    if (FALSE == g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->IsECall)
    {
        /* set call Name */
        pDesc->ContLabel[0].TxtId    = LV_LANG_TXT_ID_NONE;         // Name set after ui created
        pDesc->ContLabel[0].TxtAlign = LV_LABEL_ALIGN_LEFT;

        /* set calling SIM */
        if (g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->SimId == MMI_MODEM_SIM_1)
        {
            pDesc->ContLabel[1].TxtId  = PHONE_TEXT_ID_SIM1;
            pDesc->ContLabel[1].ImgSrc = SYMBOL_SIM1;
        }
        else
        {
            pDesc->ContLabel[1].TxtId  = PHONE_TEXT_ID_SIM2;
            pDesc->ContLabel[1].ImgSrc = SYMBOL_SIM2;
        }
        pDesc->ContLabel[1].TxtAlign    = LV_LABEL_ALIGN_LEFT;
        pDesc->ContLabel[1].SymbolAlign = LV_LABEL_ALIGN_LEFT;
    }
    else
    {
        /* set emergency call */
        pDesc->ContLabel[0].TxtId    = LV_LANG_TXT_ID_NONE;         // Name set after ui created
        pDesc->ContLabel[0].TxtAlign = LV_LABEL_ALIGN_LEFT;
        pDesc->ContLabel[1].TxtId       = LV_LANG_TXT_ID_NONE;
        pDesc->ContLabel[1].TxtAlign    = LV_LABEL_ALIGN_LEFT;
    }
    pDesc->ContLabel[0].ImgSrc = IMG_CALL_END;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_END, &FuncList, pDesc);

    g_MMI_Call_Mng.StatusAct = ACT_ID_CALL_END;
    g_MMI_Call_Mng.DisplayTimer =
        Hal_Timer_Start(UI_CALL_STATUS_TIMER_LEN, Call_Display_Timeout, (VOID *)&g_MMI_Call_Mng.StatusAct, FALSE); // start call end display timer one time
} /* Display_Call_End */

/**
 * display Call_Emergency_Calling
 * common ui: UI_Normal_NoTitle_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Emergency_Calling(VOID)
{
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_Common_Create;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    /* set called Name */
    pDesc->ContenCont.ContLabel.TxtId    = PHONE_TEXT_ID_EMERGENCY_CALLING;
    pDesc->ContenCont.ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContenCont.ContLabel.SymbolId = NULL;

    /* set button bar */
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_END_CL;
    pDesc->KeyFunc                 = Call_Key_Proc_Emergency_Calling;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_EMERGENCY_CALLING, &FuncList, pDesc);
}

/**
 * display Call_Loudsp_Inquire
 * common ui: UI_Normal_NoTitle_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Loudsp_Inquire(VOID)
{
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_Common_Create;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    /* set called Name */
    pDesc->ContenCont.ContLabel.TxtId    = PHONE_TEXT_ID_HIGH_VOL_WARNING;
    pDesc->ContenCont.ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContenCont.ContLabel.SymbolId = NULL;

    /* set button bar */
    pDesc->ButtonBar.ButtonM.Valid = TRUE;
    pDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CANCEL;
    pDesc->KeyFunc                 = Call_Key_Proc_Loudsp_Inquire;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_LOUDSP_INQUIRE, &FuncList, pDesc);
}

/**
 * display Call_Status UI
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Status(ACTIVITY_ID ActId)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_Common_Create;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_Common_Restore;

    pDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    memset(pDesc, 0, sizeof(UI_Status_Desc_t));

    /* set TxtId of Status UI */
    switch (ActId)
    {
    case ACT_ID_CALL_LOUDSP_ON:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_LOUDSPEAKER;
        break;

    case ACT_ID_CALL_LOUDSP_OFF:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_LOUDSPEAKER_OFF;
        break;

    case ACT_ID_CALL_MUTE:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_MUTE_ON;
        break;

    case ACT_ID_CALL_UNMUTE:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_MUTE_OFF;
        break;

    case ACT_ID_CALL_HOLD:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_HOLD_ON;
        break;

    case ACT_ID_CALL_BUSY:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_NUMBER_BUSY;
        break;

    case ACT_ID_CALL_EMERGENCY_ONLY_INFO:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_EMERGENCY_CALLS_ONLY;
        break;

    case ACT_ID_CALL_NEWCALL_SWAP:
        pDesc->ContLabel.TxtId = PHONE_TEXT_ID_SWAP;
        break;

    default:
        break;
    }

    pDesc->ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel.SymbolId = LV_SYMBOL_OK;
    pDesc->ContLabelAlign     = LV_ALIGN_IN_TOP_LEFT;
    pDesc->KeyFunc            = NULL;

    Nav_Forward(ACT_ID_ANY, ActId, &FuncList, pDesc);

    g_MMI_Call_Mng.StatusAct = ActId;
    g_MMI_Call_Mng.DisplayTimer =
        Hal_Timer_Start(UI_CALL_STATUS_TIMER_LEN, Call_Display_Timeout, (VOID *)&g_MMI_Call_Mng.StatusAct, FALSE); // start display timer one time
} /* Display_Call_Status */

/**
 * display Call_Loudsp_On
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Loudsp_On(VOID)
{
    Display_Call_Status(ACT_ID_CALL_LOUDSP_ON);
}

/**
 * display Call_Loudsp_Off
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Loudsp_Off(VOID)
{
    Display_Call_Status(ACT_ID_CALL_LOUDSP_OFF);
}

/**
 * display Call_Mute
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Mute(VOID)
{
    Display_Call_Status(ACT_ID_CALL_MUTE);
}

/**
 * display Call_Unmute
 * param (in) void
 * return void
 */
VOID Display_Call_Unmute(VOID)
{
    Display_Call_Status(ACT_ID_CALL_UNMUTE);
}

/**
 * display Call_Hold
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Hold(VOID)
{
    Display_Call_Status(ACT_ID_CALL_HOLD);
}

/**
 * Process Call_Unhold On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Call_Unhold(VOID *pDesc)
{
    INT8             TempChar[64];
    UI_Status_Desc_t *pTmpDesc = (UI_Status_Desc_t *)pDesc;

    Call_Common_Create(pDesc);

    /* set actived name */
    if (NULL != g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name)
    {
        sprintf(TempChar, "Active: \n%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
    }
    else
    {
        sprintf(TempChar, "Active: \n%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }

    lv_label_set_text(pTmpDesc->ContLabel.Label, TempChar);
}

/**
 * Process Call_Unhold On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Restore_Call_Unhold(VOID *pDesc)
{
    INT8             TempChar[64];
    UI_Status_Desc_t *pTmpDesc = (UI_Status_Desc_t *)pDesc;

    Call_Common_Restore(pDesc);

    /* set actived name */
    if (NULL != g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name)
    {
        sprintf(TempChar, "Active: \n\n%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Name);
    }
    else
    {
        sprintf(TempChar, "Active: \n\n%s", g_MMI_Call_Mng.Calls[g_MMI_Call_Mng.ActiveIndex]->Number);
    }

    lv_label_set_text(pTmpDesc->ContLabel.Label, TempChar);
}

/**
 * display Call_Unhold
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Unhold(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Call_Unhold;
    FuncList.OnDestroy      = Call_Common_Destory;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnRestoreState = Call_On_Restore_Call_Unhold;

    pDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    memset(pDesc, 0, sizeof(UI_Status_Desc_t));

    pDesc->ContLabel.TxtId    = LV_LANG_TXT_ID_NONE;
    pDesc->ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel.SymbolId = LV_SYMBOL_OK;
    pDesc->ContLabelAlign     = LV_ALIGN_IN_TOP_LEFT;
    pDesc->KeyFunc            = NULL;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_UNHOLD, &FuncList, pDesc);

    g_MMI_Call_Mng.StatusAct = ACT_ID_CALL_UNHOLD;
    g_MMI_Call_Mng.DisplayTimer =
        Hal_Timer_Start(UI_CALL_STATUS_TIMER_LEN, Call_Display_Timeout, (VOID *)&g_MMI_Call_Mng.StatusAct, FALSE); // start display timer one time
}

/**
 * display Call_Swap
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Swap(VOID)
{
    Display_Call_Status(ACT_ID_CALL_NEWCALL_SWAP);
}

/**
 * display Call_Busy
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Busy(VOID)
{
    Display_Call_Status(ACT_ID_CALL_BUSY);
}

/**
 * display Call_Emergency_Only
 * common ui: UI_Status_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Call_Emergency_Only_Info(VOID)
{
    Display_Call_Status(ACT_ID_CALL_EMERGENCY_ONLY_INFO);
}

/**
 * Process CAll Select Sim On Created event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Create_Call_Select_Sim(VOID *pDesc)
{
    INT8                            Operator[20];
    UI_Normal_Container_List_Desc_t *pTmpDesc
        = (UI_Normal_Container_List_Desc_t *)pDesc;
    MMI_MODEM_PLMN_RAT rat1;
    MMI_MODEM_PLMN_RAT rat2;

    Call_Common_Create(pDesc);

    /* set operator name of SIM1*/
    MMI_Modem_Get_Operator_Req(MMI_MODEM_SIM_1, Operator, &rat1);
    lv_label_set_text(pTmpDesc->ContList.ContainerList[0].u.Label2.Label, Operator);

    /* set operator name of SIM2*/
    MMI_Modem_Get_Operator_Req(MMI_MODEM_SIM_2, Operator, &rat2);
    lv_label_set_text(pTmpDesc->ContList.ContainerList[1].u.Label2.Label, Operator);
}

/**
 * Process CAll Select Sim On Destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Destroy_Call_Select_Sim(VOID *pDesc)
{
    UI_Normal_Container_List_Desc_t *pTmpDesc
        = (UI_Normal_Container_List_Desc_t *)pDesc;

    Hal_Mem_Free(pTmpDesc->ContList.ContainerList);
    Call_Common_Destory(pDesc);
    Audio_Player_Audio_Contine();
}

/**
 * Process CAll Select Sim On Restore event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Restore_Call_Select_Sim(VOID *pDesc)
{
    INT8                            Operator[20];
    UI_Normal_Container_List_Desc_t *pTmpDesc
        = (UI_Normal_Container_List_Desc_t *)pDesc;
    MMI_MODEM_PLMN_RAT rat1;
    MMI_MODEM_PLMN_RAT rat2;

    Call_Common_Restore(pDesc);

    /* set operator name of SIM1*/
    MMI_Modem_Get_Operator_Req(MMI_MODEM_SIM_1, Operator, &rat1);
    lv_label_set_text(pTmpDesc->ContList.ContainerList[0].u.Label2.Label, Operator);

    /* set operator name of SIM2*/
    MMI_Modem_Get_Operator_Req(MMI_MODEM_SIM_2, Operator, &rat2);
    lv_label_set_text(pTmpDesc->ContList.ContainerList[1].u.Label2.Label, Operator);
}

/**
 * Process CAll Select Sim On Save event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Save_Call_Select_Sim(VOID *pDesc)
{
    UI_Normal_Container_List_Desc_t *pTmpDesc
        = (UI_Normal_Container_List_Desc_t *)pDesc;
    lv_obj_t                        *CurrentBtn;

    // save index
    CurrentBtn               = lv_list_get_btn_selected(pTmpDesc->List);
    pTmpDesc->ContList.Index = lv_list_get_btn_index(pTmpDesc->List, CurrentBtn);
    Call_Common_Save(pDesc);
}

/**
 * display Dial_Call_Select_Sim
 * common ui: UI_Normal_Container_List_Desc_t
 * param (in) void
 * return void
 */
VOID Display_Dial_Call_Select_Sim(VOID)
{
    Nav_Func_List_t                 FuncList;
    UI_Normal_Container_List_Desc_t *pDesc;
    UI_Container_Base_Desc_t        *pContainerList;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_Container_List_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Call_On_Create_Call_Select_Sim;
    FuncList.OnDestroy      = Call_On_Destroy_Call_Select_Sim;
    FuncList.OnSaveState    = Call_On_Save_Call_Select_Sim;
    FuncList.OnRestoreState = Call_On_Restore_Call_Select_Sim;

    pDesc =
        (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    memset(pDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    // set title bar
    pDesc->TitleBar.TxtId    = PHONE_TEXT_ID_SIM_SEL;
    pDesc->TitleBar.TxtAlign = LV_LABEL_ALIGN_CENTER;

    // set List Count
    pDesc->ContList.ListContainerCnt = 2;
    pContainerList                   =
        (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Container_Base_Desc_t) * pDesc->ContList.ListContainerCnt);
    pDesc->ContList.ContainerList = pContainerList;
    Hal_Mem_Set(pContainerList, 0, sizeof(UI_Container_Base_Desc_t) * pDesc->ContList.ListContainerCnt);

    // set default list Index
    pDesc->ContList.Index = 0;

    // set SIM1
    pDesc->ContList.ContainerList[0].Choise = UI_BASE_OBJ_LABEL;
    pDesc->ContList.ContainerList[0].Valid  = TRUE;
    // label SIM1
    pDesc->ContList.ContainerList[0].Label.TxtId      = PHONE_TEXT_ID_SIM1;
    pDesc->ContList.ContainerList[0].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDesc->ContList.ContainerList[0].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    // Operator of SIM1
    pDesc->ContList.ContainerList[0].u.Label2.TxtId      = LV_LANG_TXT_ID_NONE;
    pDesc->ContList.ContainerList[0].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    pDesc->ContList.ContainerList[0].u.Label2.LabelAlign = LV_ALIGN_IN_TOP_RIGHT;
    // set release function
    pDesc->ContList.ContainerList[0].ReleaseFunc = Call_Rel_Func_Sim_Sel_Sim1;

    // set SIM2
    pDesc->ContList.ContainerList[1].Choise = UI_BASE_OBJ_LABEL;
    pDesc->ContList.ContainerList[1].Valid  = TRUE;
    // label SIM2
    pDesc->ContList.ContainerList[1].Label.TxtId      = PHONE_TEXT_ID_SIM2;
    pDesc->ContList.ContainerList[1].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDesc->ContList.ContainerList[1].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    // Operator of SIM2
    pDesc->ContList.ContainerList[1].u.Label2.TxtId      = LV_LANG_TXT_ID_NONE;
    pDesc->ContList.ContainerList[1].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    pDesc->ContList.ContainerList[1].u.Label2.LabelAlign = LV_ALIGN_IN_TOP_RIGHT;
    // set release function
    pDesc->ContList.ContainerList[1].ReleaseFunc = Call_Rel_Func_Sim_Sel_Sim2;

    // set button bar
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDesc->ButtonBar.ButtonM.Valid = TRUE;
    pDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    // Set key proc func
    pDesc->KeyFunc = Call_Key_Proc_Select_Sim;

    Nav_Forward(ACT_ID_ANY, ACT_ID_DIAL_CALL_SELECT_SIM, &FuncList, pDesc);
} /* Display_Dial_Call_Select_Sim */

/**
 * Process Call Dtmf Input On destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Call_On_Destroy_Call_Dtmf_Input(VOID *pDesc)
{
    UI_Normal_Ta_Only_Desc_t *pTmpDesc = (UI_Normal_Ta_Only_Desc_t *)pDesc;

    if (NULL != pTmpDesc->ContTa.TaTxt)
    {
        Hal_Mem_Free(pTmpDesc->ContTa.TaTxt);
    }
    Call_Common_Destory(pDesc);
}

/**
 * Process Call Dtmf Input On create event
 * param (in) pDesc:  VOID *
 * return  void
 */

VOID Call_On_Create_Call_Dtmf_Input(VOID *pDesc)
{
    Call_Common_Create(pDesc);
    Ime_Set_Mode(LV_IME_MODE_NUM);
    Ime_Set_SingleMode(TRUE);
}

/**
 * Process Call Dtmf Input On restore event
 * param (in) pDesc:  VOID *
 * return  void
 */

VOID Call_On_Restore_Call_Dtmf_Input(VOID *pDesc)
{
    Call_Common_Restore(pDesc);
    Ime_Set_Mode(LV_IME_MODE_NUM);
    Ime_Set_SingleMode(TRUE);
}

/**
 * display call_Dtmf_Input interface
 * common ui: UI_Normal_Ta_Only_Desc_t
 * param (in) VOID
 * return  VOID
 */
VOID Display_Call_Dtmf_Input(INT8 FirstNum)
{
    UI_Normal_Ta_Only_Desc_t *pDesc;
    Nav_Func_List_t          FuncList = { 0 };

    FuncList.OnShow         = UI_Normal_Ta_Only_Create;
    FuncList.OnCreate       = Call_On_Create_Call_Dtmf_Input;
    FuncList.OnRestoreState = Call_On_Restore_Call_Dtmf_Input;
    FuncList.OnSaveState    = Call_Common_Save;
    FuncList.OnDestroy      = Call_On_Destroy_Call_Dtmf_Input;

    pDesc = (UI_Normal_Ta_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Ta_Only_Desc_t));
    Hal_Mem_Set(pDesc, 0, sizeof(UI_Normal_Ta_Only_Desc_t));

    pDesc->TitleBar.TxtId      = LV_LANG_TXT_ID_NONE;
    pDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    pDesc->ContTa.TaTxt        = (INT8 *)Hal_Mem_Alloc(sizeof(INT8));
   *(pDesc->ContTa.TaTxt)     = FirstNum;      // set first input num
   *(pDesc->ContTa.TaTxt + 1) = '\0';
    pDesc->ContTa.TaCursorHide = FALSE;

    pDesc->ButtonBar.ButtonL.Valid = TRUE;
    pDesc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_OPT;
    pDesc->ButtonBar.ButtonM.Valid = TRUE;
    pDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_BACK;
    pDesc->ButtonBar.ButtonR.Valid = TRUE;
    pDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;

    pDesc->KeyFunc = Call_Key_Proc_Dtmf_Input;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_DTMF_INPUT, &FuncList, pDesc);
} /* Framework_Create_Dial_Main */
